<template>
  <views class="company_check_detail">
    <!-- 审核详情/审核 -->
    <div class="enterprise_info">
      <viewTitle :title="'企业基本信息'"></viewTitle>
      <div class="enterprise_info_flex">
        <el-form ref="form" label-width="auto">
          <el-form-item label="企业名称:">
            <el-input
              type="text"
              clearable
              placeholder="请输入关键字"
              v-model="company_name"
              :disabled="show"
            ></el-input>
          </el-form-item>
          <el-form-item label="企业类型:">
            <el-select v-model="company_type" placeholder="企业类型" :disabled="show">
              <el-option
                      v-for="item in company_type_list"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="统一社会信用代码:">
            <el-input
              type="text"
              clearable
              placeholder="请输入统一社会信用代码"
              v-model="organization_code"
              :disabled="show"
            ></el-input>
          </el-form-item>
          <el-form-item label="经营地址:">
            <el-input
              type="textarea"
              clearable
              placeholder="请输入经营地址"
              v-model="company_address"
              :disabled="show"
            ></el-input>
          </el-form-item>
          <el-form-item label="经营期限:">
            <el-date-picker
              v-model="deadline"
              value-format="timestamp"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :disabled="show"

            ></el-date-picker>
          </el-form-item>
          <el-form-item label="法人名称:">
            <el-input
              type="text"
              clearable
              placeholder="请输入法人名称"
              v-model="legal_person"
              :disabled="show"
            ></el-input>
          </el-form-item>
          <el-form-item label="联系方式:">
            <el-input type="text" clearable placeholder="请输入联系方式" v-model="legal_phone" :disabled="show"></el-input>
          </el-form-item>
          <el-form-item label="法人身份证号:">
            <el-input
              type="text"
              clearable
              placeholder="请输入法人身份证号"
              v-model="legal_card_no"
              :disabled="show"
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <!-- 企业业务信息 -->
    <div class="enterprise_business">
      <viewTitle :title="'企业业务信息'"></viewTitle>
      <div class="enterprise_business_flex">
        <el-form ref="form" label-width="auto">
          <el-form-item label="负责人:">
            <el-input
              type="text"
              clearable
              placeholder="请输入负责人"
              v-model="control_man"
              :disabled="show"
            ></el-input>
          </el-form-item>
          <el-form-item label="联系方式:">
            <el-input
              type="text"
              clearable
              placeholder="请输入负责人联系方式"
              v-model="control_phone"
              :disabled="show"
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
    </div>

    <!-- 附件上传 -->
    <div class="accessory">
      <viewTitle :title="'附件上传'"></viewTitle>
      <div class="accessory_flex">
        <el-form ref="form" label-width="auto" :inline="true">
          <el-form-item label="营业执照(副本):">
            <el-upload
              class="upload-demo"
              drag
              :action="uploadFile"
              :show-file-list="false"
              :on-success="licenseImgSuccess"
              :disabled="show"
            >
              <img
                v-if="license_img"
                style="width:100%;height:100%"
                :src="license_img"
                v-default-img
                alt
              />
            </el-upload>
          </el-form-item>

          <el-form-item label="法人身份证:">
            <div class="flex flexR">
              <el-upload
                class="upload-demo"
                drag
                :action="uploadFile"
                :show-file-list="false"
                :on-success="legalCardConsSuccess"
                :disabled="show"
              >
                <img
                  v-if="legal_card_cons"
                  style="width:100%;height:100%"
                  :src="legal_card_cons"
                  v-default-img
                  alt
                />  
              </el-upload>
              <div class="cardL">
                <el-upload
                  class="upload-demo"
                  drag
                  :action="uploadFile"
                  :show-file-list="false"
                  :on-success="legalCardProsSuccess"
                  :disabled="show"
                >
                  <img
                    v-if="legal_card_pros"
                    style="width:100%;height:100%"
                    :src="legal_card_pros"
                    v-default-img
                    alt
                  />  
                </el-upload>
              </div>
            </div>
          </el-form-item>
        </el-form>
      </div>
      <div class="btn-list flex flexR center flexJp" v-if="type==1">
        <el-button type="primary" @click="back">返回</el-button>
      </div>
    </div>

    <!-- 审核备注 -->
    <div class="check" v-if="type==2">
      <viewTitle :title="'审核备注'"></viewTitle>
      <div class="check_flex">
        <el-form ref="form" label-width="auto" :inline="true">
          <el-form-item label :style="{width:660+'px'}">
            <el-input type="textarea" placeholder v-model="reason" maxlength="100" show-word-limit></el-input>
          </el-form-item>
        </el-form>
        <!-- 按钮 -->
        <el-form ref="form" label-width="auto" :inline="true">
          <el-form-item label>
            <el-button type="primary" @click="check(1)">通过</el-button>
            <el-button type @click="back">取消</el-button>
            <el-button type="danger" @click="check(2)">驳回</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </views>
</template>

<script>
  import { mapGetters } from  "vuex";

export default {
  data() {
    return {
      // ----------- 企业基本信息 ----------- //
      apply_id: 0,    //申请ID
      company_name: "", // 企业名称
      organization_code: "", // 社会信用代码
      company_address: "", // 经营地址
      deadline: [], // 经营期限
      buiss_time_start: '',     //经营开始时间
      buiss_time_end: '',       //经营结束时间
      legal_person: "", // 法人名称
      legal_phone: "", // 法人联系方式
      legal_card_no: "", // 身份证号
      // ----------- 企业业务信息 ------------ //
      control_man: "", // 负责人
      control_phone: "", // 联系方式
      circuit_list: [
        {
          start_line: "", // 起始点
          end_line: "" // 结束点
        }
      ], // 线路
      options: [],
      license_img: '',      //营业执照图片
      legal_card_pros: '',      //身份证正面
      legal_card_cons: '',      //身份证反面
      show: true, // 是否禁止
      reason: "", //  备注
      type: 1, //  1 详情 2审核
      company_type: '',
      company_type_list: [
        {value:0, label:'物流'},
        {value:1, label:'快递'}
      ]
    };
  },
  computed: {
    ...mapGetters(['uploadFile']),
  },
  methods: {
    //获取详情
    getData(){
      let post_data={
        apply_id: this.apply_id
      }
      this.$raxios.post(this.$mapapi.companyApplyDetail, {data: post_data}).then(res=>{
        if(res.code==200){
          this.company_name = res.data.company_name; // 企业名称
          this.organization_code = res.data.organization_code; // 社会信用代码
          this.company_address = res.data.company_address; // 经营地址
          this.deadline = [res.data.buiss_time_start * 1000, res.data.buiss_time_end * 1000];
          this.legal_person = res.data.legal_person; // 法人名称
          this.legal_phone = res.data.legal_phone; // 法人联系方式
          this.legal_card_no = res.data.legal_card_no; // 身份证号
          this.control_man = res.data.control_man; // 负责人
          this.control_phone = res.data.control_phone; // 联系方式
          this.license_img = res.data.license_img;      //营业执照图片
          this.legal_card_pros = res.data.legal_card_pros;      //身份证正面
          this.legal_card_cons = res.data.legal_card_cons;      //身份证反面
          this.company_type = res.data.type;// 公司类型
        }else{
            this.$message.error(res.msg);
        }
      }).catch(res=>{

      })
    },

    // 加
    decrease() {
      this.circuit_list.push({
        start_line: "", // 起始点
        end_line: "" // 结束点
      });
    },
    // 减
    increase(index) {
      this.circuit_list.length > 1
        ? this.circuit_list.splice(index, 1)
        : this.$message.error("不能全部删除");
    },
    back(){
      this.$router.push('/company_check');
    },
    //上传营业执照成功
    licenseImgSuccess(res){
      console.log('licenseImgSuccess');
    },
    //上传身份证反面成功
    legalCardConsSuccess(res){
      console.log('legalCardConsSuccess');
    },
    //上传身份证正面成功
    legalCardProsSuccess(res){
      console.log('legalCardProsSuccess');
    },
    //审核情况
    check(status){
      if(status == 2 && this.reason.trim() == ''){
        this.$message.error('请填写驳回原因');
        return;
      }
      let {code, msg, data} = this.$api.sendSync(this.$mapapi.companyCheck, {apply_id: this.apply_id, status, reason: this.reason});
      if(code != 200){
        this.$message.error(msg);
        return  ;
      }
      this.$message.success(status==2?'操作成功':msg);
      this.$router.push('/company_check');

    }

  },
  mounted() {
    this.apply_id = this.$route.query.apply_id;
    this.type=this.$route.query.type;
    this.getData();
  },
  created() {}
};
</script>

<style lang="less"  :scope="true"  src="@/style/company_manager/company_check_detail.less">
</style>
